<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{msg.selNegozioSpesa}</title>
        <script type="text/javascript" src="http://map.google.com/maps/api/js?sensor=true"/>
    </h:head>
    <h:body>
        <div class="container">
            <ui:include src="Header.xhtml"/>
            <div class="content">
                <p:messages autoUpdate="true" closable="true"/>
                <h3><p:outputLabel value="#{msg.selNegozioSpesa}"/></h3>
                #{selezionaNegozio.setCliente(gestioneCliente)}
                #{selezionaNegozio.redirect()}
                <h:form id="form1">
                    <h:panelGrid id="grid1" columns="2">

                        <p:gmap id="gmap" center="#{selezionaNegozio.latLen}" zoom="15" type="ROADMAP" style="width:600px;height:400px"/>

                        <h:panelGrid id="grid2" columns="2">
                            <p:outputLabel for="provincia" value="#{msg.provinciaForm}"/>
                            <p:selectOneMenu id="provincia" required="true" disabled="#{gestioneCliente.isLogged()}" style="max-width: 500px;min-width: 230px;" requiredMessage="#{msg.provinciaRequiredM}"
                                             value="#{gestioneCliente.provincia}" converter="provinciaConverter">
                                <f:selectItem itemValue="" itemLabel="#{msg.selProvincia}" noSelectionOption="true"/>
                                <f:selectItems value="#{gestioneCliente.province}" var="p" itemLabel="#{p.nome},#{p.abbreviazione}" itemValue="#{p}"/>
                                <p:ajax event="valueChange" update="comuni , gmap, negozio" listener="#{gestioneCliente.handleComuni()}"/>
                            </p:selectOneMenu>

                            <p:outputLabel for="comuni" value="#{msg.comuneForm}"/>
                            <p:selectOneMenu id="comuni" required="true" disabled="#{gestioneCliente.isLogged()}" style="max-width: 500px;min-width: 230px;" filter="true" requiredMessage="#{msg.comuneRequiredM}" 
                                             value="#{gestioneCliente.comune}" converter="comuneConverter">
                                <f:selectItem itemLabel="#{msg.selComune}" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{gestioneCliente.comuni}" var="c" itemLabel="#{c.nome},#{c.cap}" itemValue="#{c.toString()}"/>
                                <p:ajax event="valueChange" update="negozio" />
                            </p:selectOneMenu>

                            <p:outputLabel for="negozio" value="#{msg.negozioForm}"/>
                            <p:selectOneMenu id="negozio" required="true" style="max-width: 500px;min-width: 230px;" requiredMessage="#{msg.negozioRequiredM}" 
                                             value="#{gestioneCliente.negozio}" converter="negozioConverter">
                                <f:selectItem itemLabel="#{msg.negozioSelMessage}" itemValue="" noSelectionOption="true"/>
                                <f:selectItems value="#{gestioneCliente.negozi}" var="n" itemLabel="#{n.nome}" itemValue="#{n.toString()}"/>
                            </p:selectOneMenu>
                            <p:commandButton update="form1" action="#{selezionaNegozio.continua()}" value="#{msg.continuaLable}"/>
                        </h:panelGrid>
                    </h:panelGrid>
                </h:form>
            </div>
            <ui:include src="Footer.xhtml"/>
        </div>
    </h:body>
</html>

